
<!DOCTYPE html>
<html lang='zh-cn'>
<head>
  <meta charset='utf-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <title> - 禅道</title>
  <script>window.config={"webRoot":"\/zentao\/","debug":false,"appName":"","cookieLife":30,"requestType":"PATH_INFO","requestFix":"-","moduleVar":"m","methodVar":"f","viewVar":"t","defaultView":"html","themeRoot":"\/zentao\/theme\/","currentModule":"custom","currentMethod":"ajaxmenu","clientLang":"zh-cn","requiredFields":"","router":"\/zentao\/index.php","save":"\u4fdd\u5b58","runMode":"","timeout":30000,"pingInterval":""};
  window.lang={"submitting":"\u7a0d\u5019...","save":"\u4fdd\u5b58","expand":"\u5c55\u5f00\u5168\u90e8","timeout":"\u8fde\u63a5\u8d85\u65f6\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u73af\u5883\uff0c\u6216\u91cd\u8bd5\uff01"};

  </script>
  <script>config.onlybody = "no";</script><link rel='stylesheet' href='/zentao/theme/default/zh-cn.default.css?v=12.5.3' type='text/css' media='screen' />
  <script src='/zentao/js/all.js?v=12.5.3'></script>
  <style>.alert-block{border-top:1px solid #ddd;}
  #loadingIcon {opacity: 0; transition: opacity .3s}
  #loadingIcon.active {opacity: 1}

  #menuEditor {margin-top: 10px;}
  #menuEditor .panel {border-color: #ddd;}
  #mainMenu {position: static!important; margin: 0!important; text-align: center; height: 48px; padding: 6px!important; border-top: 1px solid #eee;}
  #subNavbar {margin: 0; padding: 5px; height: 50px;}
  #navbar {padding: 5px; margin-top: 0!important; height: 60px; border-radius: 4px 4px 0 0;}
  #navbar .nav > li > a {padding: 10px 15px; border-radius: 3px;}
  #mainMenu > .nav {display: inline-block;}
  #menuEditor .nav > li > a {cursor: move;}
  #menuEditor li > a .item-hidden-icon {display: none; margin-left: 3px;}
  #menuEditor .dropdown-menu > li > a .item-hidden-icon {margin-left: 10px;}
  #menuEditor li.menu-hidden > a .item-hidden-icon {display: inline-block;}
  #menuEditor .nav > li.menu-hidden > a {border: 1px dashed #ddd; background: rgba(0,0,0,.1); margin: 0 2px; padding: 7px 11px;}
  #menuEditor .nav > li.menu-hidden > a > .dropdown{display: inline-block;}
  </style><link rel='icon' href='/zentao/favicon.ico' type='image/x-icon' />
  <link rel='shortcut icon' href='/zentao/favicon.ico' type='image/x-icon' />
  <!--[if lt IE 10]>
  <script src='/zentao/js/jquery/placeholder/min.js?v=12.5.3'></script>
  <![endif]-->
</head>
<body>
<style>
  .picker-single .picker-selection-remove{z-index: 1000;}
  .picker-selection-single:after, .picker-multi.picker-focus .picker-selections:before{font-family: ZentaoIcon !important; content: '\f0d7' !important;}
</style>
<script>
  var chooseUsersToMail = '选择要发信通知的用户...';
  if($.fn.picker)
  {
    $(document).ready(function()
    {
      $(".picker-select[data-pickertype!='remote']").picker({chosenMode: true});
      $("[data-pickertype='remote']").each(function()
      {
        var pickerremote = $(this).attr('data-pickerremote');
        $(this).picker({chosenMode: true, remote: pickerremote});
      })
    });
  }
</script>
<header id='header'>
  <div id='mainHeader'>
    <div class='container'>
      <hgroup id='heading'>
        <h1 id='companyname' title='易软天创'><a href='/temp/index' >易软天创</a>
        </h1>
      </hgroup>
      <nav id='navbar'><ul class='nav nav-default'>
        <li  data-id='my'><a href="/index/ind2" ><span> 我的地盘</span></a></li>
        <li  data-id='product'><a href='/temp/product-index-no' >产品</a></li>
        <li class='active' data-id='project'><a href='/temp/project-index-no' class='active'>项目</a></li>
        <li  data-id='qa'><a href='/temp/product-showErrorNone-qa' >测试</a></li>
        <li class='divider'></li><li  data-id='ci'><a href='/temp/repo-browse' >集成</a></li>
        <li  data-id='doc'><a href='/temp/doc' >文档</a></li>
        <li  data-id='report'><a href='/temp/report-productSummary' >统计</a></li>
        <li class='divider'></li><li  data-id='company'><a href='/temp/company-browse' >组织</a></li>
        <li  data-id='admin'><a href='/temp/admin' >后台</a></li>
      </ul>
      </nav>
      <div id='toolbar'>
        <div id="userMenu">
          <div id='searchbox'><div class='input-group'><div class='input-group-btn'><a data-toggle='dropdown' class='btn btn-link'><span id='searchTypeName'>项目</span> <span class='caret'></span></a><input type='hidden' name='searchType' id='searchType' value='project'  />
            <ul id='searchTypeMenu' class='dropdown-menu'><li ><a href='javascript:$.setSearchType("bug");' data-value='bug'>Bug</a></li><li ><a href='javascript:$.setSearchType("story");' data-value='story'>需求</a></li><li ><a href='javascript:$.setSearchType("task");' data-value='task'>任务</a></li><li ><a href='javascript:$.setSearchType("testcase");' data-value='testcase'>用例</a></li><li class='selected'><a href='javascript:$.setSearchType("project");' data-value='project'>项目</a></li><li ><a href='javascript:$.setSearchType("product");' data-value='product'>产品</a></li><li ><a href='javascript:$.setSearchType("user");' data-value='user'>用户</a></li><li ><a href='javascript:$.setSearchType("build");' data-value='build'>版本</a></li><li ><a href='javascript:$.setSearchType("release");' data-value='release'>发布</a></li><li ><a href='javascript:$.setSearchType("productplan");' data-value='productplan'>产品计划</a></li><li ><a href='javascript:$.setSearchType("testtask");' data-value='testtask'>测试单</a></li><li ><a href='javascript:$.setSearchType("doc");' data-value='doc'>文档</a></li><li ><a href='javascript:$.setSearchType("caselib");' data-value='caselib'>用例库</a></li><li ><a href='javascript:$.setSearchType("testreport");' data-value='testreport'>测试报告</a></li></ul></div><input id='searchInput' class='form-control search-input' type='search' onclick='this.value=""' onkeydown='if(event.keyCode==13) $.gotoObject();' placeholder='编号(ctrl+g)'/></div><a href='javascript:$.gotoObject();' class='btn btn-link' id='searchGo'>GO!</a></div>
          <ul id="userNav" class="nav nav-default">
            <li><a class='dropdown-toggle' data-toggle='dropdown'><span class='user-name'>admin</span><span class='caret'></span></a><ul class='dropdown-menu pull-right'><li class="user-profile-item"><a href='/temp/my-profile' class=' no-role'><div class='avatar avatar bg-secondary avatar-circle'>A</div>
              <div class="user-profile-name">admin</div><div class="user-profile-role"></div></a></li><li class="divider"></li><li><a href='/temp/my-profile' >个人档案</a>
            </li><li><a href='/temp/my-changepassword' class='iframe' data-width='500'>更改密码</a>
            </li><li class='divider'></li><li class='dropdown-submenu'><a href='javascript:;'>主题</a><ul class='dropdown-menu pull-left'><li class='selected'><a href='javascript:selectTheme("default");' data-value='default'>禅道蓝（默认）</a></li><li ><a href='javascript:selectTheme("green");' data-value='green'>叶兰绿</a></li><li ><a href='javascript:selectTheme("red");' data-value='red'>赤诚红</a></li><li ><a href='javascript:selectTheme("purple");' data-value='purple'>玉烟紫</a></li><li ><a href='javascript:selectTheme("pink");' data-value='pink'>芙蕖粉</a></li><li ><a href='javascript:selectTheme("blackberry");' data-value='blackberry'>露莓黑</a></li><li ><a href='javascript:selectTheme("classic");' data-value='classic'>经典蓝</a></li></ul></li><li class='dropdown-submenu'><a href='javascript:;'>Language</a><ul class='dropdown-menu pull-left'><li class='selected'><a href='javascript:selectLang("zh-cn");'>简体</a></li><li ><a href='javascript:selectLang("zh-tw");'>繁體</a></li><li ><a href='javascript:selectLang("en");'>English</a></li><li ><a href='javascript:selectLang("de");'>Deutsch</a></li><li ><a href='javascript:selectLang("fr");'>Français</a></li><li ><a href='javascript:selectLang("vi");'>Tiếng Việt</a></li><li ><a href='javascript:selectLang("ja");'>日本語</a></li></ul></li><li class='custom-item'><a href='custom-ajaxMenu-project-index.html?onlybody=yes' data-toggle='modal' data-type='iframe' data-icon='cog' data-width='80%'>自定义导航</a></li><li class="divider"></li><li class='dropdown-submenu'><a data-toggle='dropdown'>帮助</a><ul class='dropdown-menu pull-left'><li><a href='tutorial-start.html' class='iframe' data-class-name='modal-inverse' data-width='800' data-headerless='true' data-backdrop='true' data-keyboard='true'>新手教程</a>
            </li><li><a href='https://www.zentao.net/book/zentaopmshelp.html?fullScreen=zentao' class='open-help-tab' target='_blank' rel='noopener noreferrer'>手册</a>
            </li><li><a href='/temp/misc-changeLog' class='iframe' data-width='800' data-headerless='true' data-backdrop='true' data-keyboard='true'>修改日志</a>
            </li></ul></li>
              <li><a href='/temp/misc-about' class='about iframe' data-width='1050' data-headerless='true' data-backdrop='true' data-keyboard='true' data-class='modal-about'>关于禅道</a>
              </li><li class="divider"></li><li><a href='/temp/user-logout' >退出</a>
              </li></ul></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
  <div id='subHeader'>
    <div class='container'>
      <div id="pageNav" class='btn-toolbar'></div>
      <nav id='subNavbar'><ul class='nav nav-default'>
        <li class=' ' data-id='index'><a href='/zentao/admin/' >首页</a>
        </li>
        <li class=' ' data-id='xuanxuan'><a href='/zentao/admin-xuanxuan.html' >客户端</a>
        </li>
        <li class=' ' data-id='message'><a href='/zentao/message/' >通知</a>
        </li>
        <li class=' active' data-id='custom'><a href='/zentao/custom/' >自定义</a>
        </li>
        <li class=' ' data-id='sso'><a href='/zentao/admin-sso.html' >集成</a>
        </li>
        <li class=' ' data-id='extension'><a href='/zentao/extension-browse.html' >插件</a>
        </li>
        <li class=' ' data-id='dev'><a href='/zentao/dev-api.html' >二次开发</a>
        </li>
        <li class=' ' data-id='translate'><a href='/zentao/dev-translate.html' >翻译</a>
        </li>
        <li class=' ' data-id='data'><a href='/zentao/backup/' >数据</a>
        </li>
        <li class=' ' data-id='safe'><a href='/zentao/admin-safe.html' >安全</a>
        </li>
        <li class=' ' data-id='system'><a href='/zentao/cron/' >系统</a>
        </li>
      </ul>
      </nav>
      <div id="pageActions"><div class='btn-toolbar'></div></div>
    </div>
  </div>
</header>

<main id='main'  >
  <div class='container'>
    <div id='mainContent' class='space'>
      <div class='center-block'>
        <div class='main-header'>
          <h2>
            自定义导航        <i class='icon icon-spin icon-spinner' id='loadingIcon'></i>
          </h2>
        </div>
        <div id='menuEditor'>
          <div class='panel panel-default'>
            <nav id='navbar' class='bg-primary'>
              <ul class='nav nav-default'></ul>
            </nav>
            <nav id='subNavbar'>
              <ul class='nav nav-default'></ul>
            </nav>
            <nav id='mainMenu'>
              <ul class='nav nav-default'></ul>
            </nav>
          </div>
          <div class='text-left'>
            <div class='space-sm'>
              <div class='checkbox-primary'><input type='checkbox' name='setPublic[]' value='1'  id='setPublic1' /> <label for='setPublic1'>设为公共</label></div>        </div>
            <button id='saveMenuBtn' type='button' class='btn btn-primary btn-wide'>保存</button> &nbsp;
            <button id='closeModalBtn' type='button' class='btn btn-wide'>关闭</button> &nbsp;
            <button id='resetMenuBtn' type='button' class='btn btn-wide'>恢复默认</button> &nbsp;
            <span class='text-danger'> &nbsp; <i class="icon icon-exclamation-sign"></i> 点击显示或隐藏导航条目，拖拽来更改显示顺序。</span>
          </div>
        </div>
      </div>
    </div>
    <script>
      window.startMenu = {'module': 'project', 'method': 'templates.index'};
    </script>
  </div><script>
  $.initSidebar();
</script>

  <iframe frameborder='0' name='hiddenwin' id='hiddenwin' scrolling='no' class='debugwin hidden'></iframe>

</main><footer id='footer'>
  <div class="container">
    <ul class='breadcrumb'><li><a href='/zentao/my/' >禅道</a>
    </li><li><a href='/zentao/admin/' >后台</a>
    </li></ul>    <div id='poweredBy'>
    <small class='muted'><a href='https://api.zentao.net/goto.php?item=aiux' class='link-aiux' target='_blank'>Designed by <strong>艾体验</strong></a></small> &nbsp;
    <a href='https://www.zentao.net' target='_blank'><i class='icon-zentao'></i> 禅道12.5.3</a> &nbsp;
    <a href='https://api.zentao.net/goto.php?item=proversion&from=footer' target='_blank' id='proLink' class='text-important'>专业版 <i class='text-danger icon-pro-version'></i></a> &nbsp;           </div>
  </div>
</footer>
<div id="noticeBox"></div>
<script>
  /* Alert got messages. */
  needPing = false;
  $(function()
  {
    var windowBlur = false;
    if(window.Notification)
    {
      window.onblur  = function(){windowBlur = true;}
      window.onfocus = function(){windowBlur = false;}
    }
    setInterval(function()
    {
      $.get(createLink('message', 'ajaxGetMessage', "windowBlur=" + (windowBlur ? '1' : '0')), function(data)
      {
        if(!windowBlur)
        {
          $('#noticeBox').append(data);
          adjustNoticePosition();
        }
        else
        {
          if(data)
          {
            if(typeof data == 'string') data = $.parseJSON(data);
            if(typeof data.message == 'string') notifyMessage(data);
          }
        }
      });
    }, 300000);
  })

</script>

<script>$(function()
{
  var currentModule = startMenu['module'],
          currentMethod = startMenu['method'],
          $navbar       = $('#navbar'),
          $subNavbar    = $('#subNavbar'),
          $mainMenu     = $('#mainMenu'),
          $loadingIcon  = $('#loadingIcon'),
          $menuEditor   = $('#menuEditor'),
          menuConfig    =
                  {
                    'main':    null,
                    'module':  {},
                    'feature': {}
                  };

  var updateConfig = function($menu)
  {
    var moduleName = $menu.data('module'), methodName = $menu.data('method');
    var menu = [];
    $menu.children('.nav').children('li:not(.drag-shadow)').each(function()
    {
      var $e = $(this);
      var item = $e.children('a').data('menu');
      item.order = $e.attr('data-order');
      menu.push(item);
    });
    if(moduleName === 'main') menuConfig.main = menu;
    else if(methodName) menuConfig['feature'][moduleName][methodName] = menu;
    else menuConfig['module'][moduleName] = menu;
  }

  var updateMenu = function(moduleName, methodName, items)
  {
    var $menu = moduleName === 'main' ? $navbar : (methodName ? $mainMenu : $subNavbar);
    var items = items || (moduleName === 'main' ? menuConfig.main : (methodName ? menuConfig['feature'][moduleName][methodName] : menuConfig['module'][moduleName]));

    $menu.data({'module': moduleName, 'method': methodName});

    if(items)
    {
      var $nav = $('<ul class="nav nav-default"/>');
      $.each(items, function(idx, item)
      {
        if(!item.text || item.fixed) return;
        var $a = $('<a href="#"/>').append(item.text);
        $a.data('menu', item).append('<i class="item-hidden-icon icon icon-eye-off"></i>');
        var hidden = !!item.hidden;
        if(item.subMenu)
        {
          hidden = true;
          $a.addClass('dropdown dropdown-hover').append("<span class='caret'></span><ul class='dropdown-menu'></ul>");
          var $dropmenu = $a.find('.dropdown-menu');
          $.each(item.subMenu, function(subIdx, subItem)
          {
            subItem.order = subIdx + 1;
            var $subA = $('<a href="#"/>').append(subItem.text);
            $subA.data('menu', subItem).append('<i class="item-hidden-icon icon icon-eye-off"></i>');
            $('<li/>').attr('data-id', subItem.name).toggleClass('right', subItem.float === 'right').toggleClass('menu-hidden', !!subItem.hidden).append($subA).appendTo($dropmenu);

            hidden = subItem.hidden && hidden;
          });
          var $aInner = $a.children('a');
          if ($aInner.length)
          {
            $aInner.replaceWith($('<span>' + $aInner.text() + ' <span class="caret"></span></span>'));
            $a.addClass('dropdown-hover');
          }
          if(!$dropmenu.children().length)
          {
            $a.removeClass('dropdown dropdown-hover').find('.caret').remove();
            $dropmenu.remove();
          }
        }
        $('<li/>').attr('data-id', item.name).toggleClass('right', item.float === 'right').toggleClass('menu-hidden', hidden).append($a).appendTo($nav);
      });
      $nav.sortable({finish: function(e)
        {
          updateConfig(e.element.closest('nav'));
        }});
      $menu.children('ul').replaceWith($nav);
    }
    else
    {
      $menu.children('ul').empty();
    }
  };

  var activeCurrent = function(moduleName, methodName)
  {
    currentModule = moduleName;
    currentMethod = methodName;
    $navbar.find('li.active').removeClass('active');
    $navbar.find('li[data-id="' + moduleName + '"]:not(.right)').addClass('active');
    $subNavbar.find('li.active').removeClass('active');
    $subNavbar.find('li[data-id="' + methodName + '"]:not(.right)').addClass('active');
  };

  var loadData = function(moduleName, methodName, type, callback)
  {
    type     = type || '';
    var link = createLink('custom', 'ajaxGetMenu', 'module=' + moduleName + '&method=' + methodName + '&type=' + type, 'json');
    $loadingIcon.addClass('active');
    $.get(link, function(data)
    {
      if(data.result === 'success' && data.menu)
      {
        var menu = data.menu;
        if(menu['main'] && !menuConfig['main'])
        {
          menuConfig['main'] = menu['main'];
        }
        if(menu['module'] && !menuConfig['module'][moduleName])
        {
          menuConfig['module'][moduleName] = menu['module'];
        }
        if(menu['feature'] !== undefined && (!menuConfig['feature'][moduleName] ||  menuConfig['feature'][moduleName][methodName] === undefined))
        {
          if(!menuConfig['feature'][moduleName]) menuConfig['feature'][moduleName] = {};
          menuConfig['feature'][moduleName][methodName] = menu['feature'];
        }
        activeCurrent(moduleName, methodName);
        callback && callback(true, data);
      }
      else
      {
        callback && callback(false, data);
      }
      $loadingIcon.removeClass('active');
    }, 'json');
  };

  var formatMenuConfig = function(items)
  {
    var dataList = [];
    $.each(items, function(idx, item)
    {
      var data = {name: item.name, order: parseInt(item.order)};
      if(item.hidden) data.hidden = true;
      if(item.float) data.float = item.float;
      if(item.subMenu)
      {
        var subMenu = [];
        $.each(item.subMenu, function(sIdx, subItem)
        {
          var subData = {name: subItem.name, order: parseInt(subItem.order)};
          if(subItem.hidden) subData.hidden = true;
          if(subItem.float) subData.float = subItem.float;
          subMenu.push(subData);
        });
        data.subMenu = subMenu;
      }
      dataList.push(data);
    });
    return dataList;
  };

  $menuEditor.on('mouseenter', '.nav > li:not(.drag-shadow) > a', function()
  {
    var $a    = $(this);
    var item  = $a.data('menu');
    var $menu = $a.closest('nav');

    if($menu.is('#navbar'))
    {
      var moduleName = item.name;
      if(moduleName !== currentModule)
      {
        var methodName = item.link['method'];
        if(menuConfig['module'][moduleName])
        {
          updateMenu(moduleName);
          if(menuConfig['feature'][moduleName] && menuConfig['feature'][moduleName][methodName] !== undefined)
          {
            updateMenu(moduleName, methodName);
            activeCurrent(moduleName, methodName);
          }
          else
          {
            loadData(moduleName, methodName, 'all', function(result)
            {
              if(result)
              {
                updateMenu(moduleName, methodName);
                activeCurrent(moduleName, methodName);
              }
            });
          }
        }
        else
        {
          loadData(moduleName, methodName, 'all', function(result)
          {
            if(result)
            {
              updateMenu(moduleName);
              updateMenu(moduleName, methodName);
              activeCurrent(moduleName, methodName);
            }
          });
        }
      }
    }
    else if($menu.is('#subNavbar'))
    {
      var moduleName = item.link ? item.link['module'] : $menu.data('module');
      var methodName = item.link ? item.link['method'] : item.name;
      if(methodName !== currentMethod)
      {
        if(menuConfig['feature'][moduleName] && menuConfig['feature'][moduleName][methodName] !== undefined)
        {
          updateMenu(moduleName, methodName);
          activeCurrent($menu.data('module'), item.name);
        }
        else
        {
          loadData(moduleName, methodName, 'all', function(result)
          {
            if(result)
            {
              updateMenu(moduleName, methodName);
              activeCurrent($menu.data('module'), item.name);
            }
          });
        }
      }
    }
  }).on('click', '.nav>li>a,.dropdown-menu>li>a', function(e)
  {
    var $a   = $(this);
    var item = $a.data('menu');
    if(!item) return;
    if($a.find('.dropdown-menu').length) return;

    var $menu      = $a.closest('nav');
    var moduleName = item.link && item.link['module'] ? item.link['module'] : item.name;
    var methodName = item.link && item.link['method'] ? item.link['method'] : '';
    item.hidden    = !item.hidden;
    if($menu.is('#subNavbar'))
    {
      moduleName = currentModule;
      methodName = item.name;
    }
    $a.parent().toggleClass('menu-hidden', item.hidden);

    /* Update parent menu by sub menu. */
    if($a.parent().parent().hasClass('dropdown-menu'))
    {
      var hidden = true;
      $a.parent().parent().children().each(function()
      {
        hidden = $(this).hasClass('menu-hidden') && hidden;
      });

      $a.parent().parent().parent().parent().toggleClass('menu-hidden', hidden);
    }

    updateConfig($menu);
    e.stopPropagation();
  });

  $('#saveMenuBtn').click(function()
  {
    var postData = [{'module': 'main', value: formatMenuConfig(menuConfig.main)}];
    $.each(menuConfig['module'], function(moduleName, items)
    {
      postData.push({'module': moduleName, value: formatMenuConfig(items)});
    });

    $.each(menuConfig['feature'], function(moduleName, feature)
    {
      if(!feature) return;
      $.each(feature, function(methodName, items)
      {
        if(items) postData.push({'module': moduleName, 'method': methodName, value: formatMenuConfig(items)});
      });
    });

    postData  = $.map(postData, JSON.stringify);
    setPublic = $('#setPublic1').prop('checked') ? 1 : 0;

    $.post(createLink('custom', 'ajaxSetMenu'), {menus: postData, setPublic: setPublic}, function(data)
    {
      if(data.result === 'success') window.parent.location.reload()
      if(data.message) alert(data.message);
    }, 'json').error(function(e) {alert(lang.timeout);});
  }).on('mouseenter', function() {$menuEditor.addClass('preview')})
          .on('mouseout', function() {$menuEditor.removeClass('preview')});

  loadData(currentModule, currentMethod, 'all', function(result)
  {
    if(result)
    {
      updateMenu('main');
      updateMenu(currentModule);
      updateMenu(currentModule, currentMethod);
      activeCurrent(currentModule, currentMethod);
    }
  });

  $('#closeModalBtn').click(function()
  {
    window.parent.$.closeModal();
  });

  $('#resetMenuBtn').click(function()
  {
    var setPublic = $('#setPublic1').prop('checked') ? 1 : 0;
    hiddenwin.location.href = createLink('custom', 'ajaxRestoreMenu', "public=" + setPublic);
  });
});

</script>
</body>
</html>
